package com.young.pattern.simpleFactoryPattern;

import lombok.extern.slf4j.Slf4j;
import sun.util.locale.provider.LocaleServiceProviderPool;

/**
 * 简单工厂模式:
 * 图标工厂类,充当工厂类
 */
@Slf4j
public class ChartFactory {

    //  静态工厂方法
    public static Chart getChart(String type){
        Chart chart = null;
        if (type.equalsIgnoreCase("histogram")){
            chart = new HistogramChart();
            log.info("初始化设置柱状图...");
        }else if (type.equalsIgnoreCase("pie")){
            chart = new PieChart();
            log.info("初始化设置饼状图....");
        }else if (type.equalsIgnoreCase("line")){
            chart = new LineChart();
            log.info("初始化设置折线图.....");
        }else{
            chart = new LineChart();
            log.info("初始化设置异常,使用默认的折线图");
        }
        return chart;
    }

}
